/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainForm.java
 *
 * Created on 26/11/2009, 22:23:46
 */

package sigbar.view;

import sigbar.access.BDInterface;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.MouseEvent;

/**
 *
 * @author Hudson
 * Modificado por hdhzero
 * Modificado por Denis
 */
public class MainForm extends javax.swing.JFrame {

    private EstoqForm estoqForm;
    private GerenteForm gerenteForm;
    private int opc;//opcao de escolha do tipo do usuario
    BDInterface dbConection;
    private SellerForm vendedorForm;

    public BDInterface getDbConection() {
        return dbConection;
    }

    public void setDbConection(BDInterface dbConection) {
        this.dbConection = dbConection;
    }

    /** Creates new form MainForm */
    public MainForm(BDInterface dbConection, int opc) {
        initComponents();
        init();
        pack();
        setDbConection(dbConection);
        setOpc(opc);
    }

    public int getOpc() {
        return opc;
    }

    public void setOpc(int opc) {
        this.opc = opc;
    }

    /**
     * Inicializa a interface customizada.
     */
    private void init() {
        gerenteForm = new GerenteForm();
        estoqForm = new EstoqForm(getDbConection());
        vendedorForm = new SellerForm();

        GridBagConstraints grid = new GridBagConstraints();
        grid.insets = new Insets(0, 0, 0, 0);
        grid.anchor = GridBagConstraints.NORTHWEST;
        grid.gridx = 0;
        grid.gridy = 0;
        grid.gridheight = 1;
        grid.gridwidth = 1;
        grid.fill = GridBagConstraints.NONE;
        grid.weightx = 0;
        grid.weighty = 0;

        add(gerenteForm,grid);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        arquivoMenu = new javax.swing.JMenu();
        logonMenuItem = new javax.swing.JMenuItem();
        sairMenuItem = new javax.swing.JMenuItem();
        modulosMenu = new javax.swing.JMenu();
        vendaMenuItem = new javax.swing.JMenuItem();
        superMenuItem = new javax.swing.JMenuItem();
        gerenteMenuItem = new javax.swing.JMenuItem();
        ajudaMenu = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("AZTech - Tecnologia de A a Z - SIGBAR");
        setResizable(false);
        getContentPane().setLayout(new java.awt.GridBagLayout());

        arquivoMenu.setText("Arquivo");

        logonMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        logonMenuItem.setText("Conectar...");
        arquivoMenu.add(logonMenuItem);

        sairMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        sairMenuItem.setText("Sair");
        sairMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sairMenuItemActionPerformed(evt);
            }
        });
        arquivoMenu.add(sairMenuItem);

        jMenuBar1.add(arquivoMenu);

        modulosMenu.setText("Modulos");

        vendaMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.ALT_MASK));
        vendaMenuItem.setText("Modulo Vendedor");
        vendaMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vendaMenuItemActionPerformed(evt);
            }
        });
        modulosMenu.add(vendaMenuItem);

        superMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        superMenuItem.setText("Modulo Supervisor");
        superMenuItem.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                superMenuItemMouseClicked(evt);
            }
        });
        superMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                superMenuItemActionPerformed(evt);
            }
        });
        modulosMenu.add(superMenuItem);

        gerenteMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.ALT_MASK));
        gerenteMenuItem.setText("Modulo Gerente");
        gerenteMenuItem.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                gerenteMenuItemMouseClicked(evt);
            }
        });
        gerenteMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gerenteMenuItemActionPerformed(evt);
            }
        });
        modulosMenu.add(gerenteMenuItem);

        jMenuBar1.add(modulosMenu);

        ajudaMenu.setText("Ajuda");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
        jMenuItem1.setText("Sobre...");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        ajudaMenu.add(jMenuItem1);

        jMenuBar1.add(ajudaMenu);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        About about = new About();
        about.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void gerenteMenuItemMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gerenteMenuItemMouseClicked
        
}//GEN-LAST:event_gerenteMenuItemMouseClicked

    private void superMenuItemMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_superMenuItemMouseClicked
        
    }//GEN-LAST:event_superMenuItemMouseClicked

    private void gerenteMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gerenteMenuItemActionPerformed
        remove(gerenteForm);
        remove(estoqForm);
        remove(vendedorForm);

        GridBagConstraints grid = new GridBagConstraints();
        grid.insets = new Insets(0, 0, 0, 0);
        grid.anchor = GridBagConstraints.NORTHWEST;
        grid.gridx = 0;
        grid.gridy = 0;
        grid.gridheight = 1;
        grid.gridwidth = 1;
        grid.fill = GridBagConstraints.NONE;
        grid.weightx = 0;
        grid.weighty = 0;

        add(gerenteForm,grid);
        
        pack();
    }//GEN-LAST:event_gerenteMenuItemActionPerformed

    private void superMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_superMenuItemActionPerformed
        remove(gerenteForm);
        remove(estoqForm);
        remove(vendedorForm);

        GridBagConstraints grid = new GridBagConstraints();
        grid.insets = new Insets(0, 0, 0, 0);
        grid.anchor = GridBagConstraints.NORTHWEST;
        grid.gridx = 0;
        grid.gridy = 0;
        grid.gridheight = 1;
        grid.gridwidth = 1;
        grid.fill = GridBagConstraints.NONE;
        grid.weightx = 0;
        grid.weighty = 0;

        add(estoqForm,grid);

        pack();
    }//GEN-LAST:event_superMenuItemActionPerformed

    private void vendaMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vendaMenuItemActionPerformed
        remove(gerenteForm);
        remove(estoqForm);
        remove(vendedorForm);

        GridBagConstraints grid = new GridBagConstraints();
        grid.insets = new Insets(0, 0, 0, 0);
        grid.anchor = GridBagConstraints.NORTHWEST;
        grid.gridx = 0;
        grid.gridy = 0;
        grid.gridheight = 1;
        grid.gridwidth = 1;
        grid.fill = GridBagConstraints.NONE;
        grid.weightx = 0;
        grid.weighty = 0;

        add(vendedorForm,grid);
        pack();
    }//GEN-LAST:event_vendaMenuItemActionPerformed

    private void sairMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sairMenuItemActionPerformed
        dispose();
    }//GEN-LAST:event_sairMenuItemActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu ajudaMenu;
    private javax.swing.JMenu arquivoMenu;
    private javax.swing.JMenuItem gerenteMenuItem;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem logonMenuItem;
    private javax.swing.JMenu modulosMenu;
    private javax.swing.JMenuItem sairMenuItem;
    private javax.swing.JMenuItem superMenuItem;
    private javax.swing.JMenuItem vendaMenuItem;
    // End of variables declaration//GEN-END:variables

}
